package common.impl;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;

public class SmsHandle {
	private static final String SendUrl="http://mb345.com/WS/Send.aspx";
	private static final String CorpID="LKSDK0230598";//账户名
	private static final String Pwd="123456";//密码 
	public static int sendSMS(String Mobile,String Content) throws MalformedURLException, UnsupportedEncodingException {
		URL url = null;
		String send_content=URLEncoder.encode(Content, "GBK");//发送内容
		StringBuffer sb = new StringBuffer();
		sb.append(SendUrl);
		sb.append("?");
		sb.append("CorpID=").append(CorpID);
		sb.append("&Pwd=").append(Pwd);
		sb.append("&Mobile=").append(Mobile);
		sb.append("&Content=").append(send_content);
		url = new URL(sb.toString());
		BufferedReader in = null;
		int inputLine = 0;
		try {
			in = new BufferedReader(new InputStreamReader(url.openStream()));
			inputLine = new Integer(in.readLine()).intValue();
		} catch (Exception e) {
			inputLine=-2;
		}
		return inputLine;
	}
}
